import _ from "lodash";
// 引入深拷贝
import { TOGGLE_COLLAPSED_TYPE } from "./types";
// 用户习惯把当前状态放在浏览器存储里
// 用 store.js操作
import LS from "store";
const reducer = (
    state = {
        // 可以给个初始默认值 初始值放在localStorage里
        // 如果取不到第二个参数可以给个默认值false
        collapsed: LS.get("collapsed", false),
    },
    action
) => {
    const newState = _.cloneDeep(state);
    const { type } = action;
    switch (type) {
        case TOGGLE_COLLAPSED_TYPE:
            newState.collapsed = !newState.collapsed;
            break;
        default:
            break;
    }
    return newState;
};

export default reducer;